export const retry = (assertion: () => any, { interval = 20, timeout = 300 } = {}) => {
    return new Promise((resolve, reject) => {
        const startTime = Date.now();

        const tryAgain = () => {
            setTimeout(() => {
                try {
                    resolve(assertion());
                } catch (err) {
                    Date.now() - startTime > timeout ? reject(err) : tryAgain();
                }
            }, interval);
        };

        tryAgain();
    });
};
